package WordCount;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class WordCountReducer extends Reducer<Text, LongWritable,Text,LongWritable> {
    @Override//reducer方法对分完组后的kv对进行分组
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        //key=china value=[1,1,1,1]

        long count=0;
        for (LongWritable value : values) {
            count =count+ value.get();

        }
        context.write(key,new LongWritable(count));
    }
}
